package common.util;

public class MyUtil {

	public static String rPad(String str , int length) {
		
		
		
		return rPad(str , length , " ");
	}
	
	public static String rPad(String str , int length , String character) {
		
		if(str == null) return "";
		
		if(character.equals("")) character = " ";
		
		
		int gap = length - str.length();
		
		if( gap <= 0 ) {
			return str;
		}
		
		for(int i = 0 ; i < gap ; i++) {
			str+= character;
		}
		
		return str;
	}
	
	public static String lPad(String str , int length) {
		
		
		
		return rPad(str , length , " ");
	}
	
	public static String lPad(String str , int length , String character) {
		
		if(str == null) return "";
		
		if(character.equals("")) character = " ";
		
		
		int gap = length - str.length();
		
		if( gap <= 0 ) {
			return str;
		}
		
		for(int i = 0 ; i < gap ; i++) {
			str = character + str;
		}
		
		return str;
	}
	
	public static String addToLeft( String src , String add ) {
		try {
			if(src != null) {
				if(!src.equals("")) {
					if(add != null) {
						if(!add.equals("")) {
							return add + src;
						}
					}
				}
			}
			return "";
		}
		catch(Exception e) {
			e.printStackTrace();
			return "";
		}
	}
	
	public static String addToRight( String src , String add ) {
		try {
			if(src != null) {
				if(!src.equals("")) {
					if(add != null) {
						if(!add.equals("")) {
							return src + add;
						}
					}
				}
			}
			return "";
		}
		catch(Exception e) {
			e.printStackTrace();
			return "";
		}
	}
}
